package cn.wolfcode.wolf2w.web.controller;


import cn.wolfcode.wolf2w.annotation.UserParam;
import cn.wolfcode.wolf2w.cache.service.IPersonalRedisService;
import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.domain.UserInfo;
import cn.wolfcode.wolf2w.service.IPersonalService;
import cn.wolfcode.wolf2w.service.IStrategyService;
import cn.wolfcode.wolf2w.util.JsonResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("personal")
public class PersonalController {
    @Autowired
    private IPersonalService personalService;

    @Autowired
    private IPersonalRedisService personalRedisService;

    @Autowired
    private IStrategyService strategyService;

    @RequestMapping("strategyList")
    public Object strategyList(@UserParam UserInfo userInfo){

        List<String> sids = personalRedisService.queryStrategy(userInfo.getId());

        List<Strategy> strategies = strategyService.queryStrategyById(sids);
        JSONObject.toJSONString(strategies);
        return JsonResult.success(strategies);

    }

}
